package com.alks.entity.data.enums.biocontrol;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum TimeCaluEnum {
    CALU_ONE("1","按订单评审核算"),
    CALU_TWO("2","按门槛天数核算");

    private String code;
    private String type;

    TimeCaluEnum(String code, String type) {
        this.code = code;
        this.type = type;
    }

    /**
     * 根据编号获取方法
     * @param code
     * @return
     */
    public static String getType(String code){
        for (TimeCaluEnum value : TimeCaluEnum.values()) {
            if (value.code.equals(code)){
                return value.type;
            }
        }
        return null;
    }

    /**
     * 根据方法获取编号
     * @param type
     * @return
     */
    public static String getCode(String type){
        for (TimeCaluEnum value : TimeCaluEnum.values()) {
            if (value.type.equals(type)){
                return value.code;
            }
        }
        return null;
    }

    /**
     * 获取计算方法列表
     * @return
     */
    public static List<String> getTypeList(){
        return Arrays.stream(TimeCaluEnum.values())
                .map(a->a.type).collect(Collectors.toList());
    }
}
